<?php
include_once 'inc/config.inc.php';
include_once 'inc/mysql.inc.php';
include_once 'inc/tool.ins.php';
$template['title'] = '登录';
     $link = connect();
     if(is_login($link)){
           skip('index.php','glyphicon-ban-circle','你已经登录了');
     }

     if(isset($_POST['submit'])){
         include 'inc/check_login.inc.php';
         $query="select * from user where sid='{$_POST['sid']}' and  password={$_POST['pwd']} ";
         $result=execute($link,$query);
          if(mysqli_num_rows($result)==1){

           setcookie('hbw[sid]',$_POST['sid'],time()+$_POST['time']);
           setcookie('hbw[pwd]',$_POST['pwd'],time()+$_POST['time']);

           $_SESSION["sid"]=$_POST['sid'];


            skip('index.php','glyphicon-ok-sign','登录成功');
          }else{
             skip('login.php','glyphicon-remove-sign','用户名或密码填写错误');
          }

     }



?>



<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <title>登录注册页面</title>
    <link rel="stylesheet" href="css/stylelogin.css">

    <link rel="stylesheet" href="https://unpkg.com/animate.css@3.5.2/animate.min.css" />

    <style>
       button{
            margin-bottom:19px;
        }

        .zddl{
          font-family: "Roboto", sans-serif;
          text-transform: uppercase;

          background: #4CAF50;
          width: 100%;
          border: 0;

          color: #FFFFFF;
          font-size: 14px;

        }

    </style>
</head>

<body>
<div class="login-page animated fadeInUpBig ">
    <div class="form">

        <form  method="post">
            <input placeholder="学号" name="sid">
            <input  placeholder="密码"  name="pwd" type="password">



            <label><input name="vcode" type="text" placeholder="验证码" /></label>
            <img class="vcode" src="show_code.php" />
            <br><br>
              <button name="submit">登录</button>
            <label> <span class="zddl">自动登录<span>
            <br><br>
                <select style="width:236px;height:25px;background-color: #fafafa;font-size: 14px;" name="time">
                    <option value="3600">1小时内</option>
                    <option value="86400">1天内</option>
                    <option value="259200">3天内</option>
                    <option value="2592000">30天内</option>
                </select>

            </label>

            <p class="message">还没有账号？<a href="register.php" >立即注册</a> </p>
        </form>

    </div>
</div>



</body>

</html>